<?php

abstract class BaseModel extends CActiveRecord{
    protected function beforeValidate(){
        if($this->isNewRecord){
            $this->createdDate = $this->updatedDate = new CDbExpression('NOW()');
            $this->createdUserId = $this->updatedUserId = Yii::app()->user->id;
        }
        else{
            $this->updatedDate = new CDbExpression('NOW()');
            $this->updatedUserId = Yii::app()->user->id;
        }
        return parent::beforeValidate();
    }
}
?>
